package com.example.mardan.views;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.mardan.adapter.SongciAdapter;
import com.example.mardan.viewmodel.SongciViewModel;
import com.example.read.R;

public class SongciChapterActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private SongciAdapter adapter;
    private SongciViewModel viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_songci);

        recyclerView = findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new SongciAdapter(this);
        recyclerView.setAdapter(adapter);

        viewModel = new ViewModelProvider(this).get(SongciViewModel.class);
        viewModel.getChapters().observe(this, chapters -> {
            adapter.setChapters(chapters);
        });
    }
}